<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.validate.js" />"></script>
<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">
var validator ;
function insVali () {
	validator.resetForm();
}
$(document).ready(function() {
	//检查是什么状态，更新或新增
	var flag="${flag}";
	if(flag=="update"){
		$("#termVerForm").attr("action","<%=basePath%>/termVer/updatetTermVerManage.ct");
	}
	// 字符最大长度验证（一个中文字符长度为2）
	jQuery.validator.addMethod("stringMaxLength", function(value,element, param) {
		var length = value.length;
		for ( var i = 0; i < value.length; i++) {
			if (value.charCodeAt(i) > 127) {
				length++;
			}
		}
		return this.optional(element) || (length <=param);
	}, $.validator.format("长度不能大于{0}!"));	
	
	validator = $("#termVerForm").validate({
		debug:true,
		submitHandler : function(form) {
			$("#btnAdd").attr("disabled",true);
				form.submit();
		},
		success : function (label) {
		},
		rules : {
			"termVer.manufacturer" : {required : true},
			"termVer.modelId" : {required : true},
			"termVer.issueTs" : {required : true},
			"termVer.versionId" :{required   : true,remote:{
				type:'post',
				url:'valiareaCodeTerm.ct',
				dataType: 'json',
				data:{
					"termVer.manufacturer":function(){
						return $('#termVerForm_termVer_manufacturer').val();
					  	 },
					"termVer.modelId":function(){
						return $('#termVerForm_termVer_modelId').val();
					  	},
					"termVer.issueTs":function(){
						return $('#termVerForm_termVer_issueTs').val();
						},
					"termVer.versionId":function(){
						return $('#termVerForm_termVer_versionId').val();
						},
					 "termVer.id": function(){
						return $("#objId").val();
						}
				}
			
				
			 },
		},
			
			},
		messages : {
			"termVer.manufacturer" : {required : "*请输入厂商名称"},
			"termVer.modelId" : {required : "*请输入型号"},
			"termVer.versionId" : {required : "*请输入版本号",
				                   remote: "*区域编号已存在"	
			},
			"termVer.issueTs" : {required : "*必选"}
		},errorPlacement: function(error, element) {
		    if ( element.is(":radio") ) 
		        error.appendTo ( element.parent() ); 
		    else if ( element.is(":checkbox") ) 
		        error.appendTo ( element.parent() ); 
		    else if ( element.is("input") ) {
		    	error.appendTo ( element.parent() ); 
		    }
		    else 
		        error.insertAfter(element); 
		} 

	});
});


</script>
</head>
<body>
			<s:form id="termVerForm" action="/termVer/insertTermVerManage.ct" method="post"  theme="simple"  >
				<table width="100%" class="tb" >
			        <tr class="tb-line">
			            <td class="tb-td" colspan="6">
				            <div class="tb-h2">POS收单运营管理平台</div>
					   	</td>
			        </tr>
	               <tr class="tb-line bg-gray">
			            <td class="tb-td" colspan="4"><div class="tb-h3"><s:if test="#request.flag ==\"update\"">
			                	修改终端版本</s:if>
			                	<s:else>
			                	添加终端版本
			                	</s:else></div></td>
			        </tr>
					<tr class="tb-line">
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4">厂商：</div>
			            </td>
                    <td class="tb-td">
                    <!--修改  -->
						<s:hidden id="objId" name="termVer.id" value="%{termVer.id}"></s:hidden>
						<%-- <s:hidden name="termVer.id" value="%{termVer.id}"></s:hidden> --%>
                        <s:if test="#request.flag ==\"update\"">
                             <label class="tb-input-normal">
                             <s:textfield maxLength="200" theme="simple"  cssClass="queryWidth" disabled="true"   name="termVer.manufacturer" value="%{termVer.manufacturer}"></s:textfield>	
				              </label> 
							<%-- <s:hidden name="area.insCode" value="%{area.insCode}"></s:hidden> --%>
		                </s:if>
						<s:else>
                             <label class="tb-input-normal">
                             <s:textfield maxLength="200" theme="simple"  cssClass="queryWidth" disabled="disabled"   name="termVer.manufacturer" value="%{termVer.manufacturer}"></s:textfield>	
				              </label> 
						</s:else>
						<font color="red">*</font>
					</td>
						
						
						<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">型号：</div>
			            </td>
			            <td class="tb-td" >			             	
								<s:if test="#request.flag ==\"update\"">
									<label class="tb-input-normal">
                             			<s:textfield maxLength="200" theme="simple"  cssClass="queryWidth" disabled="true"  name="termVer.modelId" value="%{termVer.modelId}"></s:textfield>	
				             		 </label> 
									
								</s:if>
								<s:else>
									<label class="tb-input-normal">
			             				<s:textfield maxLength="100" theme="simple" cssClass="queryWidth" disabled="disabled" name="termVer.modelId" value="%{termVer.modelId}"></s:textfield>	
									</label>
								</s:else>
							<font color="red">*</font>
						</td>
					</tr>
					
					<tr class="tb-line">					
				    	<td align="right" class="tb-td" style="width:110px;">
				        		<div class="tb-h4">版本号：</div>
			            </td>
			             <td class="tb-td" >			             	
								<s:if test="#request.flag ==\"update\"">
									<label class="tb-input-normal">
									<s:textfield maxLength="100" theme="simple"   name="termVer.versionId" cssClass="queryWidth"  value="%{termVer.versionId}"></s:textfield>	
									</label>
								</s:if>
								<s:else>
									<label class="tb-input-normal">
			             			<s:textfield maxLength="100" theme="simple"  name="termVer.versionId" cssClass="queryWidth"  value="%{termVer.versionId}"></s:textfield>	
									</label>
								</s:else>
							<font color="red">*</font>
						</td>
			            
						<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">发布日期：</div>
			            </td>
			             <td class="tb-td" >			             	
								<s:if test="#request.flag ==\"update\"">
									<label class="tb-input-normal">
                 						<s:textfield id="issueTs" name="termVer.issueTs" value="%{termVer.issueTs}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});" cssClass="queryWidth"/></label>
									</label>
								</s:if>
								<s:else>
									<label class="tb-input-normal">
			             				<s:textfield id="issueTs" name="termVer.issueTs" value="%{termVer.issueTs}" onfocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});" cssClass="queryWidth"/></label>
									</label>
								</s:else>
							<font color="red">*</font>
						</td>
					</tr>
					<tr>
			    		<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                			<div class="tb-h4">版本状态：</div>
            			</td>
						<td class="tb-line">
							<s:if test="#request.flag ==\"update\"">
                				<label class="tb-input-lengthen">
                				                      
									<s:select list="#{'1':'有效','0':'无效' }" name="termVer.isValId" value="%{termVer.isValid}"   cssClass="queryWidth"/>
								</label>
							</s:if>
							<s:else>
								<label class="tb-input-lengthen">
									<s:select list="#{'1':'有效','0':'无效' }" name="termVer.isValId" cssClass="queryWidth"/> 
								</label>
							</s:else>
						</td>
						
			            <td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title"></div>
			            </td>
			             <td class="tb-td" >			             	
								<s:if test="#request.flag ==\"update\"">
									<label class="tb-input-normal">
									</label>
								</s:if>
								<s:else>
									<label class="tb-input-normal">
									</label>
								</s:else>
						</td>
					</tr>	
				</table>		
		      <table width="100%" border="0" cellspacing="0" class="table">
		           	<tr class="tb-line">
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
					<tr class="tb-line">
			            <td class="tb-td line-submit" align="center" colspan="4">
			                <label class="tb-input-submit">		                
			                	<s:submit id="btnAdd" value="保  存" />								
							</label>
			                <label class="tb-input-submit">
								<input type="reset" value="取  消"/>
							</label>
							<label class="tb-input-submit">
								<input type="button" value="返回" onclick="history.back()"/>
							</label>
						</td>
					</tr>
            </table>
			</s:form>	
</body>
</html>
